#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 25;
const int INF = 2e8 + 5;

int n, m;
int g[25][25];
int d[1 << 20][20];

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  rep(i, 0, n - 1) rep(j, 0, n - 1) cin >> g[i][j];
  rep(i, 1, n - 1) d[1][i] = INF;
  d[1][0] = 0;
  rep(s, 2, (1 << n) - 1) {
    rep(i, 0, n - 1) d[s][i] = INF;
    if ((s & 1) == 0) continue;
    rep(i, 0, n - 1) {
      if (((s >> i) & 1) == 0) continue;
      int s0 = s ^ 1 << i;
      rep(j, 0, n - 1) {
        if (((s0 >> j) & 1) == 0) continue;
        d[s][i] = min(d[s][i], d[s0][j] + g[j][i]);
      }
    }
  }
  cout << d[(1 << n) - 1][n - 1];
  return 0;
}